package com.newtouch.bxzs.policy.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.newtouch.bxzs.common.base.em.CompanyParameterTypeEnum;
import com.newtouch.bxzs.common.base.em.SystemParamsEnum;
import com.newtouch.bxzs.common.base.util.RedisUtils;
import com.newtouch.bxzs.common.base.util.SendHttpRequestUtils;
import com.newtouch.bxzs.policy.model.bo.PreservationBO;
import com.newtouch.bxzs.policy.model.bo.enterprise.*;
import com.newtouch.bxzs.policy.model.bo.family.PolicyUserListBO;
import com.newtouch.bxzs.policy.model.vo.PolicyInfoPageVO;
import com.newtouch.bxzs.policy.model.vo.PolicyUserListVO;
import com.newtouch.bxzs.policy.model.vo.PreservationProgressInfoVO;
import com.newtouch.bxzs.policy.model.vo.enterprise.*;
import com.newtouch.bxzs.policy.service.EnterprisePolicyInsuranceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 企业单管理实现类
 *
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2021/1/7 13:33</td>
 * <td>linhongxi</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author linhongxi
 * @version 1.0.0
 * @since 1.0.0
 */
@Service
public class EnterprisePolicyInsuranceServiceImpl implements EnterprisePolicyInsuranceService {

    @Autowired
    private RedisUtils redisUtils;


    /**
     * 根据保单号查询企业单详情信息
     * com.newtouch.bxzs.policy.service.PolicyService#getIndividualPolicyInfo
     * @param enterprisePolicyInfoVO 企业单详情信息查询条件
     * @return 企业单详情信息
     */
    @Override
    public EnterprisePolicyBO getEnterprisePolicyInfoInsurance(EnterprisePolicyInfoVO enterprisePolicyInfoVO) {
        SendHttpRequestUtils<EnterprisePolicyInfoVO> sendHttpRequest = new SendHttpRequestUtils<>();
        String url = redisUtils.get(SystemParamsEnum.ENTERPRISE_POLICY_INFO.getCode());
        return JSON.toJavaObject(sendHttpRequest.sendHttpRequestToJson(enterprisePolicyInfoVO, url),EnterprisePolicyBO.class);
    }

    /**
     * 根据保单号获取企业单保全列表
     *
     * @param policyInfoPageVO 企业单详情--保全信息查询条件
     *
     * @return 企业单详情--保全信息
     */
    @Override
    public List<PreservationBO> getEnterprisePolicyPreservationInsurance(PolicyInfoPageVO policyInfoPageVO){
        SendHttpRequestUtils<PolicyInfoPageVO> sendHttpRequest = new SendHttpRequestUtils<>();
        String url = redisUtils.get(SystemParamsEnum.ENTERPRISE_POLICY_INFO_PRESERVATION.getCode());
        return JSONObject.parseArray(sendHttpRequest.sendHttpRequestToArray(policyInfoPageVO,url).toJSONString(),PreservationBO.class);
    }

    /**
     * 根据保单号获取理赔列表
     *
     * @param policyInfoPageVO 企业单详情--理赔信息查询条件
     *
     * @return 企业单详情--理赔信息
     */
    @Override
    public List<EnterpriseClaimsBO> getEnterprisePolicyClaimsInsurance(PolicyInfoPageVO policyInfoPageVO){
        SendHttpRequestUtils<PolicyInfoPageVO> sendHttpRequest = new SendHttpRequestUtils<>();
        String url = redisUtils.get(SystemParamsEnum.ENTERPRISE_POLICY_INFO_CLAIMS.getCode());
        return JSONObject.parseArray(sendHttpRequest.sendHttpRequestToArray(policyInfoPageVO, url).toJSONString(),EnterpriseClaimsBO.class);
    }
    /**
     * 根据保单号获取企业单人员清单列表
     *
     * @param policyUserListVO 企业单详情--人员清单信息查询条件
     *
     * @return 企业单详情--人员清单信息
     */
    @Override
    public List<PolicyUserListBO> getEnterprisePolicyUserListInsurance(PolicyUserListVO policyUserListVO){
        SendHttpRequestUtils<PolicyUserListVO> sendHttpRequest = new SendHttpRequestUtils<>();
        String url = redisUtils.get(SystemParamsEnum.ENTERPRISE_POLICY_INFO_USER.getCode());
        return  JSONObject.parseArray(sendHttpRequest.sendHttpRequestToArray(policyUserListVO, url).toJSONString(),PolicyUserListBO.class);
    }
    /**
     * 根据查询条件获取新契约进度列表
     *
     * @param enterprisePolicyNewContractVO 企业单新契约进度列表信息查询条件
     *
     * @return 企业单新契约进度列表信息
     */
    @Override
    public List<EnterprisePolicyNewContractBO> getNewContractListByEnterprisePolicyInsurance(EnterprisePolicyNewContractVO enterprisePolicyNewContractVO){
        SendHttpRequestUtils<EnterprisePolicyNewContractVO> sendHttpRequest = new SendHttpRequestUtils<>();
        String url = redisUtils.get(SystemParamsEnum.ENTERPRISE_POLICY_NEW_CONTRACT.getCode());
        return JSONArray.parseArray(sendHttpRequest.sendHttpRequestToArray(enterprisePolicyNewContractVO, url).toJSONString(),EnterprisePolicyNewContractBO.class);
    }

    /**
     * 根据保单号获取新契约进度详情
     *
     * @param enterprisePolicyNewContractInfoVO 企业单新契约进度详情信息查询条件
     *
     * @return 企业单新契约进度详情信息
     */
    @Override
    public EnterprisePolicyNewContractBO getNewContractInfoByEnterprisePolicyInsurance(EnterprisePolicyNewContractInfoVO enterprisePolicyNewContractInfoVO){
        SendHttpRequestUtils<EnterprisePolicyNewContractInfoVO> sendHttpRequest = new SendHttpRequestUtils<>();
        String url = redisUtils.get(SystemParamsEnum.ENTERPRISE_POLICY_NEW_CONTRACT_INFO.getCode());
        return JSON.toJavaObject(sendHttpRequest.sendHttpRequestToJson(enterprisePolicyNewContractInfoVO, url),EnterprisePolicyNewContractBO.class);
    }

    /**
     * 根据投保单号获取企业单新契约详情人员清单列表
     *
     * @param enterprisePolicyNewContractUserListVO 企业单新契约进度详情--人员清单信息查询条件
     * @return 企业单新契约进度详情--人员清单信息
     */
    @Override
    public List<PolicyUserListBO> getNewContractUserListByEnterprisePolicyInsurance(EnterprisePolicyNewContractUserListVO enterprisePolicyNewContractUserListVO ){
        SendHttpRequestUtils<EnterprisePolicyNewContractUserListVO> sendHttpRequest = new SendHttpRequestUtils<>();
        String url = redisUtils.get(SystemParamsEnum.ENTERPRISE_POLICY_NEW_CONTRACT_INFO_USER.getCode());
        return JSONObject.parseArray(sendHttpRequest.sendHttpRequestToArray(enterprisePolicyNewContractUserListVO, url).toJSONString(),PolicyUserListBO.class);
    }

    /**
     * 根据查询条件获取保全进度列表
     *
     * @param enterprisePreservationVO 企业单保全进度列表信息查询条件
     *
     * @return 企业单保全进度列表信息
     */
    @Override
    public List<EnterprisePreservationProgressInfoBO> getPreservationListByEnterPrisePolicyInsurance(EnterprisePreservationVO enterprisePreservationVO){
        SendHttpRequestUtils<EnterprisePreservationVO> sendHttpRequest = new SendHttpRequestUtils<>();
        String url = redisUtils.get(SystemParamsEnum.ENTERPRISE_POLICY_PRESERVATION.getCode());
        return JSONObject.parseArray(sendHttpRequest.sendHttpRequestToArray(enterprisePreservationVO, url).toJSONString(),EnterprisePreservationProgressInfoBO.class);
    }
    /**
     * 根据保单号获取保全进度详情
     *
     * @param preservationProgressInfoVO 企业单保全进度详情信息查询条件
     *
     * @return 企业单保全进度详情信息
     */
    @Override
    public EnterprisePreservationProgressInfoBO getPreservationInfoByEnterPrisePolicyInsurance(PreservationProgressInfoVO preservationProgressInfoVO){
        SendHttpRequestUtils<PreservationProgressInfoVO> sendHttpRequest = new SendHttpRequestUtils<>();
        String url = redisUtils.get(CompanyParameterTypeEnum.ENTERPRISE_POLICY_PRESERVATION_INFO.getCode());
        return JSON.toJavaObject(sendHttpRequest.sendHttpRequestToJson(preservationProgressInfoVO, url),EnterprisePreservationProgressInfoBO.class);
    }

    /**
     * 根据查询条件获取理赔进度列表
     *
     * @param enterpriseClaimsVO 企业单理赔进度列表信息查询条件
     *
     * @return 企业单理赔进度列表信息
     */
    @Override
    public List<EnterpriseClaimsProgressBO> getClaimsProgressListByEnterprisePolicyInsurance(EnterpriseClaimsVO enterpriseClaimsVO){
        SendHttpRequestUtils<EnterpriseClaimsVO> sendHttpRequest = new SendHttpRequestUtils<>();
        String url = redisUtils.get(CompanyParameterTypeEnum.ENTERPRISE_POLICY_CLAIMS.getCode());
        return JSONObject.parseArray(sendHttpRequest.sendHttpRequestToArray(enterpriseClaimsVO, url).toJSONString(),EnterpriseClaimsProgressBO.class);
    }

    /**
     * 根据保单号获取理赔进度--个人列表
     *
     * @param policyUserListVO 企业单理赔进度--个人列表信息查询条件
     *
     * @return 企业单保全进度--个人列表信息
     */
    @Override
    public List<EnterpriseClaimsProgressBO> getClaimsProgressUserListByEnterprisePolicyInsurance(PolicyUserListVO policyUserListVO){
        SendHttpRequestUtils<PolicyInfoPageVO> sendHttpRequest = new SendHttpRequestUtils<>();
        String url = redisUtils.get(CompanyParameterTypeEnum.ENTERPRISE_POLICY_CLAIMS_QUERY.getCode());
        return  JSONObject.parseArray(sendHttpRequest.sendHttpRequestToArray(policyUserListVO, url).toJSONString(),EnterpriseClaimsProgressBO.class);
    }

    /**
     * 根据保单号获取理赔进度--批次列表
     *
     * @param policyInfoPageVO 企业单理赔进度--批次列表信息查询条件
     *
     * @return 企业单理赔进度--批次列表信息
     */
    @Override
    public List<EnterpriseClaimsProgressBO> getClaimsProgressBatchListByEnterprisePolicyInsurance(PolicyInfoPageVO policyInfoPageVO){
        SendHttpRequestUtils<PolicyInfoPageVO> sendHttpRequest = new SendHttpRequestUtils<>();
        String url = redisUtils.get(CompanyParameterTypeEnum.ENTERPRISE_POLICY_CLAIMS_BATCH.getCode());
        return JSONObject.parseArray(sendHttpRequest.sendHttpRequestToArray(policyInfoPageVO, url).toJSONString(),EnterpriseClaimsProgressBO.class);
    }
    /**
     * 根据查询条件获取满期保单列表
     *
     * @param enterpriseExpirationPolicyVO 企业单满期列表信息查询条件
     *
     * @return 企业单满期列表信息
     */
    @Override
    public List<EnterpriseExpirationPolicyBO> getExpirationPolicyListByEnterprisePolicyInsurance(EnterpriseExpirationPolicyVO enterpriseExpirationPolicyVO){
        SendHttpRequestUtils<EnterpriseExpirationPolicyVO> sendHttpRequest = new SendHttpRequestUtils<>();
        String url = redisUtils.get(CompanyParameterTypeEnum.ENTERPRISE_POLICY_EXPIRATION.getCode());
        return JSONObject.parseArray(sendHttpRequest.sendHttpRequestToArray(enterpriseExpirationPolicyVO, url).toJSONString(),EnterpriseExpirationPolicyBO.class);
    }

    /**
     * 根据查询条件获取续期保单列表
     *
     * @param enterpriseRenewalPolicyVO 企业单续期列表信息查询条件
     *
     * @return 企业单续期列表信息
     */
    @Override
    public List<EnterpriseRenewalPolicyBO> getRenewalPolicyListByEnterPrisePolicyInsurance(EnterpriseRenewalPolicyVO enterpriseRenewalPolicyVO){
        SendHttpRequestUtils<EnterpriseRenewalPolicyVO> sendHttpRequest = new SendHttpRequestUtils<>();
        String url = redisUtils.get(CompanyParameterTypeEnum.ENTERPRISE_POLICY_RENEWAL.getCode());
        return JSONObject.parseArray(sendHttpRequest.sendHttpRequestToArray(enterpriseRenewalPolicyVO, url).toJSONString(),EnterpriseRenewalPolicyBO.class);
    }

}
